// 懒加载导入组件
const Login = () => import("@/pages/Login");
const Home = () => import("@/pages/Home");
const Search = () => import("@/pages/Search");
const Register = () => import("@/pages/Register");
const Detail = () => import("@/pages/detail");
const AddCartSuccess = () => import("@/pages/AddCartSuccess");
const ShopCart = () => import("@/pages/ShopCart");
const Trade = () => import("@/pages/Trade");
const Pay = () => import("@/pages/Pay");
const PaySuccess = () => import("@/pages/PaySuccess");

const Center = () => import("@/pages/Center");




const Test = () => import("@/pages/Test");


export default  [
    {
        path:"/",
        component:Home
    },
    {
        path:"/test",
        component:Test
    },
    {
        path:"/login",
        component:Login,
        meta:{
            isHiddenFooter:true,  
        }
    },
    {
        path:"/search",
        component:Search
    },
    {
        path:"/register",
        component:Register,
        meta:{
            isHiddenFooter:true,  
        }
    },
    {
        path:"/detail/:id",
        component:Detail
    },
    {
        path:"/addcart_success",
        component:AddCartSuccess,
        beforeEnter(to,from,next){
            if(from.path.slice(0,7) === "/detail"){
                next()
            }else{
                next("/");
            }
        }
    },
    {
        path:"/shopcart",
        component:ShopCart
    },
    {
        path:"/trade",
        component:Trade
    },
    {
        path:"/pay",
        component:Pay,
        beforeEnter(to,from,next){
           if(from.path === "/trade"){
                next();
           }else{
                next("/");
           }
        }
    },
    {
        path:"/paysuccess",
        component:PaySuccess
    },
    {
        path:"/center",
        component:Center
    }
    
]